package com.midou.administration.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.midou.administration.bo.DelDesk;
import com.midou.administration.bo.DeskBo;
import com.midou.administration.bo.TypeDesk;
import com.midou.administration.entity.Desk;
import com.midou.administration.entity.DeskType;
import com.midou.administration.service.DeskService;
import com.midou.administration.service.impl.DeskServiceImpl;
import com.midou.administration.service.impl.DeskTypeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.midou.administration.service.impl.DeskServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author MrChen
 * @since 2021-03-24
 */
@RestController
@RequestMapping("/administration/desk")
public class DeskController {
    @Resource
    private DeskService deskService;
    @Autowired
    private DeskServiceImpl service;
    @RequestMapping("/query-desk")
    public List<Desk> queryDesk(@RequestBody TypeDesk typeDesk){
        System.out.println(typeDesk.getShopid()+"------------------------------------");
        return deskService.queryDesk(typeDesk);
    }
    @RequestMapping("/add-desk")
    public Integer addDesk(@RequestBody Desk desk){
        return deskService.save(desk);
    }

    @RequestMapping("/query-qr-path")
    public String queryQrPath(@RequestBody Integer id){
        return deskService.queryQrPath(id);
    }
    @RequestMapping("/del-desk")
    public Integer delDesk(@RequestBody DelDesk delDesk){
        return deskService.delDesk(delDesk);
    }

    @RequestMapping("/query-desk-one")
    public Desk queryDeskOne(@RequestBody Integer id){
        return deskService.queryDeskOne(id);
    }
    @RequestMapping("/modify-desk")
    public Integer modifyDesk(@RequestBody Desk desk){
        return deskService.modifyDesk(desk);
    }
    /**
     * 小程序查找桌台信息
     */
    @RequestMapping("/queryXcx")
    public List<Desk> qeryXcx(Integer id){
        return service.queryXcx(id);
    }
    /**
     * 根据类型查找桌台
     */
    @RequestMapping("/queryName")
    public  List<Desk> queryName(Integer id,Integer did){
        System.out.println(id+"+"+did);
        List<Desk> list=service.queryName(id,did);
        System.out.println(list);
        return  service.queryName(id,did);
    }




    @Autowired
    DeskServiceImpl deskServiceimpl;

    /**
     * 按照商户id查询该商户下的所有就餐人数
     * @param buid
     * @return
     */
    @RequestMapping("/doBuidFindSumPeople")
    public int doBuidFindSumPeople(@RequestBody int buid){
        int people = deskServiceimpl.doBuidFindSumPeople(buid);
        return people;
    }

    /**
     * 根据类型查询
     */
    @RequestMapping("/queryBytypeid")
    public List<Desk> queryBytypeid(int typeId,int buId){
        return this.deskService.queryDeskByTypeId(typeId,buId);
    }

    //二级菜单桌台信息
    @RequestMapping("/quyuQuery")
    public List<DeskType> quyuQuery(@RequestBody DeskBo deskBo){
        return this.deskServiceimpl.quyuQuery(deskBo);
    }

    //二级菜单区域桌台信息
    @RequestMapping("/zhuotaiQuery")
    public List<Desk> zhuotaiQuery(@RequestBody DeskBo deskBo){
       return this.deskServiceimpl.zhuotaiQuery(deskBo);

    }

}
